﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;

namespace FlightSearchServer
{
    public class FlightSearchService : IFlightSearchService
    {
        int connects = 0;

        public TicketList SearchTickets(string date, string source, string destination)
        {
            Console.WriteLine("In SearchTickets!" +  connects);

            connects += 1;
            Console.WriteLine("In SearchTickets!" + connects);



            TicketSellingServiceClient proxy = new TicketSellingServiceClient("BasicHttpBinding_ITicketSellingService");
            Object tickets;
            using (new OperationContextScope((IContextChannel)proxy.InnerChannel))
            {
                tickets = proxy.SearchTickets(date, source, destination);
            }


            Console.WriteLine("After!");


            WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;

            Console.WriteLine("Exiting SearchTickets!");
            return new TicketList();
        }
    }
}
